import cv2
import datetime

# 调用摄像头，PC电脑中0为内置摄像头，1为外接摄像头
video = cv2.VideoCapture(0)
# 判断video是否打开
judge = video.isOpened()
while judge:
    ret, frame = video.read()
    df = datetime.datetime.now()
    date = df.strftime('%Y%m%d%H%M%S')
    fpath = f'/data/webdav/camera/{date}.jpg'
    print('fpath', fpath)
    cv2.imwrite(fpath, frame)
    break

# 释放窗口
video.release()
cv2.destroyAllWindows()
